#! /bin/bash

#----------------------------------
#define all the stock information 
#-----------------------------------

# wget http://table.finance.yahoo.com/table.csv?s=600090.ss
# wget http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx/getStockInfoByCode?theStockCode=sh600090
#http://www.webservicelist.com/api/web_services_business_finance_xignitefunddataapi_websitedesign217669.html

#Shanghai exchange A

#[ ${#@} -ne 1] && echo "usage $0 <number of stockinfo>" && exit 1

 
if [ ! -d ./tmp ]; then   
   echo "creating a new temporary folder"
   mkdir tmp
else
   echo "Clear old folder"
   rm -rf tmp
   mkdir tmp
fi

 printf "6%05d\n" {0..2000} | xargs -t -P200 -n1 -n3 -I"Stockcode" wget  http://table.finance.yahoo.com/table.csv?s=Stockcode.ss -O ./tmp/Stockcode.ss

 printf "6%05d\n" {0..2000} | xargs -t -P1 -n3 -n6 -I"Stockcode" sed -i '1,1d' ./tmp/Stockcode.ss  

 printf "6%05d\n" {0..2000} | xargs -t -P1 -n3 -n6 -I"Stockcode"  sed 's/$/,Stockcode/' ./tmp/Stockcode.ss >> ./tmp/allData.data 
 
 
 
 